package net.sureon.biz;

import net.sureon.app.AppContext;
import net.sureon.common.SureonConstants;
import net.sureon.common.exception.SureonException;

public class BizMgr {
	private UserMgr userMgr;
	private GroupMgr groupMgr;
	private CompanyMgr companyMgr;
	/**
	 * @return the userMgr
	 */
	public UserMgr getUserMgr() {
		return userMgr;
	}
	/**
	 * @param userMgr the userMgr to set
	 */
	public void setUserMgr(UserMgr userMgr) {
		this.userMgr = userMgr;
	}
	/**
	 * @return the groupMgr
	 */
	public GroupMgr getGroupMgr() {
		return groupMgr;
	}
	/**
	 * @param groupMgr the groupMgr to set
	 */
	public void setGroupMgr(GroupMgr groupMgr) {
		this.groupMgr = groupMgr;
	}
	/**
	 * @return the companyMgr
	 */
	public CompanyMgr getCompanyMgr() {
		return companyMgr;
	}
	/**
	 * @param companyMgr the companyMgr to set
	 */
	public void setCompanyMgr(CompanyMgr companyMgr) {
		this.companyMgr = companyMgr;
	}
	
	public CategoryAble getCategoriedObject(int category) throws SureonException{
		switch(category){
		case SureonConstants.BIZ_CATEGORY_USER:
		    if(AppContext.getUserID() > 0){
		        return userMgr.getUser(AppContext.getCompanyID(), AppContext.getUserID());
		    }
		case SureonConstants.BIZ_CATEGORY_GROUP:
			if(AppContext.getGroupID() > 0){
			    return groupMgr.getGroup(AppContext.getCompanyID(), AppContext.getGroupID());
			}
		case SureonConstants.BIZ_CATEGORY_COMPANY:
			if(AppContext.getCompanyID() > 0){
			    return companyMgr.getCompany(AppContext.getCompanyID());
			}
		default:
			return null;
		}
	}
}
